#!/bin/csh
# 1d_movie.csh
###################################################################
# The scripts reads all grd_****_.dat files contained in $dirout
# and runs ./1d_profiles.csh for each of them
#
# - Set the simulation directory containing YACC's output 
#   in the file "simulation.dir"
# - Run the script using:
#   ./1d_movie.csh 
#   Set 0 or 1 in 1d_profiles.csh to select the fields 
#   for which the profile must be plotted
##################################################################

source simulation.dir

if (! -d $dirout) then
  echo $dirout 'does not exist. Check the path stored in the variable "dirout" '
  exit
endif

set dirplots = {$dirout}Plots/Profiles/ 

#------------------------------------------------------
# Run 1d_profiles.csh on all grd files in $dirout
#------------------------------------------------------
if (! -d $dirplots) then
  mkdir $dirplots
endif

set files = (`ls ${dirout}grd*.dat | grep -v "grd_restart*"`)

foreach file ($files)

   set nchar = `echo $file | awk '{print length($0)}'`
   set n1 = `echo "scale=1; $nchar - 10" | bc -l`
   set n2 = `echo "scale=1; $nchar - 5" | bc -l`

   set tstep = `echo $file | cut -c ${n1}-${n2}`

   if (! -e ${dirplots}temperature_profile_${tstep}.jpg ) then
	./1d_profiles.csh $tstep 
	echo ""
   endif

end

